import { SlashAppContext } from 'slash-admin';
import 'slash-admin/dist/style.css';
import { routesArray } from '@/router';
import {Layer} from 'slash-layer';
import {config} from './MyLayerConfig';

async function start() {
  await SlashAppContext.createApp(null);
  SlashAppContext.setAppConfig({
    //http请求基础路径
    httpBaseUrl:window.sessionStorage.getItem("baseUrl") || "http://paramcimsit.sit.paramst.cn/api", // 'http://192.168.32.200:8080/api', //
    //文件上传预览基础路径
    fileBaseUrl: window.sessionStorage.getItem('baseUrl') || 'http://paramcimsit.sit.paramst.cn',
    fileUploadUri:
      window.sessionStorage.getItem('fileUploadUri') || 'api/resourceApp/resource/uploadFile',
    loginSuccessRouterPath: '/navigation/welcome',
    loginSuccessRouterTitle: '欢迎页',
    loginSuccessInnerOpen: true,
    loginPath: '/login',
    fontSizeCoefficient: 1
  });
  await SlashAppContext.init();
  Layer.initConfig(Object.assign(config, {
    fontSizeConfig: SlashAppContext.getAppConfig().fontSizeThemeConfig,
    fontSizeCoefficient: 1
  }));

  await SlashAppContext.addRouters(routesArray);
  await SlashAppContext.routerReady();
  console.log('路由情况:{}', SlashAppContext.getRouter());
  // await SlashAppContext.use(ElementPlus, {locale: locale, size: 'medium', zIndex: 3000})
  SlashAppContext.setLogoName('测试系统');
  SlashAppContext.getRouter()?.isReady();

  SlashAppContext.mount('#app', false);
  console.log('上下文:', SlashAppContext._app);
}

start();
